package com.fzj.charging.cost.dao.repository.impl;

import com.fzj.charging.cost.dao.repository.CostRedisRepository;
import com.fzj.charging.cost.pojo.entity.ChargingCostRule;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class CostRedisRepositoryImpl implements CostRedisRepository {
    @Autowired
    private RedisTemplate<String,List<ChargingCostRule>> redisTemplate;
    @Override
    public List<ChargingCostRule> selectCostRuleList(Integer stationId) {
        ValueOperations<String, List<ChargingCostRule>> valueOperations = redisTemplate.opsForValue();
        String key = "charging_cost_rule"+stationId;
        return valueOperations.get(key);
    }

    @Override
    public void saveCostRuleList(Integer stationId,List<ChargingCostRule> chargingCostRuleList) {
        redisTemplate.opsForValue().set("charging_cost_rule"+stationId,chargingCostRuleList);
    }
}
